<?php

error_reporting(E_ALL);

/**
 * ELEARNING - class.ControladorRecursos.php
 *
 * $Id$
 *
 * This file is part of ELEARNING.
 *
 * Automatically generated on 07.12.2011, 17:12:07 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * include ModeloRecursos
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.ModeloRecursos.php');

/**
 * include Recursos
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Recursos.php');

/**
 * include Usuarios
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Usuarios.php');

/**
 * include VistaRecursos
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.VistaRecursos.php');

/* user defined includes */
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B6F-includes begin
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B6F-includes end

/* user defined constants */
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B6F-constants begin
// section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B6F-constants end

/**
 * Short description of class ControladorRecursos
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ControladorRecursos
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    /**
     * Short description of attribute modelo
     *
     * @access public
     * @var Integer
     */
    public $modelo = null;

    /**
     * Short description of attribute vista
     *
     * @access public
     * @var Integer
     */
    public $vista = null;

    /**
     * Short description of attribute recurso
     *
     * @access public
     * @var Integer
     */
    public $recurso = null;

    /**
     * Short description of attribute usuario
     *
     * @access public
     * @var Integer
     */
    public $usuario = null;

    /**
     * Short description of attribute mensaje
     *
     * @access public
     * @var String
     */
    public $mensaje = null;

    // --- OPERATIONS ---

    /**
     * Short description of method Lista
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Lista()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B86 begin
		$cadena=$this->modelo->GetAllRows();
		
		$this->vista->Lista("header.php",$cadena);
		$this->vista->Lista("VistaListaRecursos.php",$cadena);
		$this->vista->Lista("footer.php",$cadena);
		exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B86 end
    }

    /**
     * Short description of method Alta
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Alta($datos)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B88 begin
		$this->modelo->InsertRow($datos);
			$this->Lista();
			$this->mensaje="Recurso registrado con Exito";
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B88 end
    }

    /**
     * Short description of method Borrar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Borrar($id)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B8A begin
		$this->modelo->DeleteRow($id);
		$this->Lista();
		exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B8A end
    }

    /**
     * Short description of method Mostrar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Mostrar()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B8C begin
			$this->vista->Alta("header.php");
			$this->vista->Alta("VistaAltaRecursos.php");
			$this->vista->Alta("footer.php");
				exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B8C end
    }

    /**
     * Short description of method MostrarEditar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function MostrarEditar($valorid) 
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B8E begin
		$cadena= $this->modelo->GetId($valorid);
				$this->vista->Editar("header.php",$cadena);
				$this->vista->Editar("VistaEditarRecursos.php",$cadena);
				$this->vista->Editar("footer.php",$cadena);
				exit();
				
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B8E end
    }

    /**
     * Short description of method MostrarBorrar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function MostrarBorrar($valorid)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B90 begin
		$cadena= $this->modelo->GetId($valorid);				
				$this->vista->Borra("header.php",$cadena);
				$this->vista->Borra("VistaBajaRecursos.php",$cadena);
				$this->vista->Borra("footer.php",$cadena);
				exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B90 end
    }

    /**
     * Short description of method Editar
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function Editar($datos)
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B92 begin
		$this->modelo->UpdateRow($datos);
			$this->Lista();
			exit();
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B92 end
    }

    /**
     * Short description of method ControladorRecursos
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function ControladorRecursos()
    {
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B94 begin
		$this->modelo = new ModeloRecursos();		
		$this->vista = new VistaRecursos();
		$this->usuarios = new Usuarios();
		$this->recursos = new Recursos();
		
		if ($this->usuarios->IsLogged()==true && @$_REQUEST['opcion'] == null && @$_REQUEST['registrorec'] == null && @$_REQUEST['borrar'] == null && @$_REQUEST['editarrec'] == null && @$_REQUEST['borrarrec'] == null)
		{	
			$this->Lista();		
		}else
		{
			if(@$_REQUEST['salir'] != null)
			{
				$this->usuario->LogOut();
			}
			elseif(@$_REQUEST['opcion'] == 'agregar')
			{
				$this->Mostrar();
			}
			elseif(@$_REQUEST['registrorec'] != null)
			{
				$this->Alta($_REQUEST);
			}
			elseif(@$_REQUEST['opcion'] == 'desplegar')
			{
				if(@$_REQUEST['dato']== 1){
				$this->MostrarBorrar(@$_REQUEST['id']);
				}
				if(@$_REQUEST['dato']== 2){
				$this->MostrarEditar(@$_REQUEST['id']);
				}
			}
			elseif(@$_REQUEST['editarrec'] != null) 
			{
				$this->Editar($_REQUEST);
			}
			elseif(@$_REQUEST['borrarrec'] != null)
			{
				$this->Borrar(@$_REQUEST['idrecurso']);
			}
		}
        // section -64--88-1-105--75424b28:1340c1872aa:-8000:0000000000000B94 end
    }

} /* end of class ControladorRecursos */

?>